package com.yeban.javase.day15.test.test0;

import java.io.*;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/10/27
 */
public class Review1 {

    public static void main(String[] args) {
        try(
                InputStream is = Review1.class.getResourceAsStream("file_utf8.txt");
                InputStreamReader isr = new InputStreamReader(is, "UTF-8");
                BufferedReader br = new BufferedReader(isr);     // 字符流

                OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("src/com/yeban/javase/day15/file_gbk.txt"), "GBK");
        ) {
                char[] chars = new char[1024];
                int len;
                while((len = br.read(chars)) != -1) {
                    osw.write(chars, 0, len);
                }
                System.out.println("写入成功！");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
